var longestConsecutive = function(nums) {
    let maxCount = 0;
    nums = new Set(nums);
    
    for (let value of nums) {
      if (nums.has(value - 1)) continue;
      
      let curr = value, count = 1;
      while (nums.has(value + 1)) {
        nums.delete( value + 1 );
        value++;
        count++;
      }
      maxCount = Math.max(maxCount, count);
    }
    
    return maxCount;
  }
  
  作者：ignore_express
  链接：https://leetcode-cn.com/problems/longest-consecutive-sequence/solution/js-ha-xi-fa-by-ignore_express/
  来源：力扣（LeetCode）
  著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。